<?php

!defined('IN_VIFRAME') && die('Access Denied.');

class OTinyMessage extends TObject {
	
	protected
		$_Content = '';
		
	protected
		$_Style   = '';
	
	public function __construct($content, $style = '') {
		$this->_Style = Config::get('Message.Tiny.Style');
		
		$this->setContent($content)->setStyle($style);
	}
	
	public function getContent() {
		return $this->_Content;
	}
	
	public function setContent($content) {
		$this->_Content = $content;
		
		return $this;
	}
	
	public function getStyle() {
		return $this->_Style;
	}
	
	public function setStyle($key, $value = null) {
		if (is_array($key)) {
			foreach ($key as $cntKey => $cntValue) {
				$this->_Style .= "$cntKey:$cntValue;";
			}
		} elseif (is_null($value)) {
			$this->_Style .= $key;
		} else {
			$this->_Style .= "$key:$value;";
		}
		
		return $this;
	}

	public function flush($die = false) {
		$output  = '';
		$output .= "<pre style='{$this->_Style}'>\n";
		$output .= $this->_Content;
		if ($die) $output .= Config::get('Message.System.DieMassage');
		$output .= "\n</pre>\n";

		echo($output);
		if ($die) die();
		
		return $this;
	}
}